Skip to content

Transaction.Timeout property (#129) #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SergeiPavlov
Copy link
Contributor

@SergeiPavlov SergeiPavlov commented Jul 5, 2023

This property is useful for multi-command transactions.
Each DbCommand.CommandTimeout property is assigned to remaining time until Transaction.Timestamp + Timeout deadline.

Also:

  • Refactor Transaction class

* Transaction.Timeout property

* Optimize Transaction ctor

* Optoimize Transaction

* Optimize Transaction.Guid

* Refactoring: PreDbCommandExecuting() method

* Optimize Transaction.Outermost

* Add missed cancellationToken
@alex-kulakov
Copy link
Contributor

alex-kulakov commented Sep 3, 2023

  1. There is no such native setting as Transaction timeout. It starts and ends when user wants.
  2. Commands are expected to have either default timeout or the timeout which was set in SessionConfiguration.CommandTimeout. But this behavior treats commands unequally which makes them order-dependent. This inequality makes commands execution untransparent and illogical for the user. Depending on this setting the same query may be executed successfully or failed because some artificial obstacle (because otherwise query would've executed successfully).
  3. It interferes with async tokens, which adds even more unpredictability to the equation.
  4. This custom behavior is possible to realize without changes in DataObjects.Net code. You have an event for transaction opening to get transaction, you have an extensions collection where you can store whatever you want and you have an event on command executing which gives you DbCommand to set CommandTimeout property (or any other property) as you wish.

@SergeiPavlov
Copy link
Contributor Author

SergeiPavlov commented Sep 3, 2023

4. This custom behavior is possible to realize without changes

Yes, "On events" was our initial implementaion

But after we implemented another feaure "SessionGuard" for detecting concurrent usage of Session, it had a conflict with TransactionTimeout feature, because of order of events.
So the Eventless implementation is necessary for us.

@alex-kulakov
Copy link
Contributor

It still conflicts with bunch of other cases. I hardly can allow this. It is very shady in terms of predictability. Maybe we can improve extendibility in a way that will allow you to implement it like a session service or something.

What about sessionhandler replacement?

@alex-kulakov
Copy link
Contributor

As I understand you need some code which will work not in context of all sessions, like events do, but in context of one exact session. Am I right?

@SergeiPavlov
Copy link
Contributor Author

I did not use SessionHandler, have to learn it.

Regarding to Transaction.Timeout, we need to limit execution time of code like:

var tx = session.OpenTransaction();
tx.Timeout = Timespan.FromSeconds(10);
for (int i = 0; i < N; ++i) {
    // some DO query
}
tx.Complete();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants